/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.srcptit.trainning.thompv.btvn1;
import java.util.Scanner;
/**
 *
 * @author SONY
 */
public class Bai7Muc1 
{
    static boolean fibo(int n)
    {
        int s=0;
        while(n>0)
        {
            s=s+n%10;
            n=n/10;
        }
        if(s==1||s==2||s==3||s==5||s==8||s==13||s==21||s==34||s==55) return true;
        return false;
    }
    static boolean tn(int n)
    {
        int goc=n,dao=0;
        while(n>0)
        {
            dao=dao*10+n%10;
            n=n/10;
        }
        if(goc==dao) return true;
        return false;
    }
    static boolean ngto(int n)
    {
            for(int i=2;i<=(int)Math.sqrt(n);i++)
            if(n%i==0) return false;
            return  true;
    }
    public static void main(String[] args)
    {
        for(int i=10000;i<=9999999;i++)
            if(fibo(i)&&tn(i)&&ngto(i))
                System.out.println(i);
    }
}
